package net.cctms.zhishu;

import android.os.CountDownTimer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.webkit.JavascriptInterface;
import android.widget.Button;
import android.widget.Toast;

import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.facade.callback.NavigationCallback;
import com.alibaba.android.arouter.launcher.ARouter;

import net.cctms.zhishu.webAppFramework.model.PicEntity;
import net.cctms.zhishu.webAppFramework.ui.GestureImageActivity;
import net.cctms.zhishu.webAppFramework.ui.video.MyVideoActivity;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;

import wendu.dsbridge.CompletionHandler;
import wendu.dsbridge.DWebView;

public class DSBridgeActivity extends AppCompatActivity {
    Button goarouter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dsbridge);
        goarouter = findViewById(R.id.goarouter);
        goarouter.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ARouter.getInstance().build("/zhishu/ArouterActivity").navigation(DSBridgeActivity.this, new NavigationCallback() {
                    @Override
                    public void onFound(Postcard postcard) {
                        Toast.makeText(DSBridgeActivity.this, "找到对应的页面", Toast.LENGTH_LONG).show();
                    }

                    @Override
                    public void onLost(Postcard postcard) {
                        Toast.makeText(DSBridgeActivity.this, "找不到了", Toast.LENGTH_LONG).show();
                    }

                    @Override
                    public void onArrival(Postcard postcard) {
                        Toast.makeText(DSBridgeActivity.this, "跳转完了", Toast.LENGTH_LONG).show();
                    }

                    @Override
                    public void onInterrupt(Postcard postcard) {
                        Toast.makeText(DSBridgeActivity.this, "被拦截了", Toast.LENGTH_LONG).show();
                    }
                });
            }
        });
        DWebView dwebView = (DWebView) findViewById(R.id.webview);
        // set debug mode
        DWebView.setWebContentsDebuggingEnabled(true);
        dwebView.addJavascriptObject(new JsApi(DSBridgeActivity.this), null);
        dwebView.loadUrl("file:///android_asset/js-call-native.html");
    }


}
